<?php include("head.php"); ?>
    <div class="sui-layout">
		  <div class="sidebar">
<?php include("leftmenu.php"); ?>	  	
		  </div>
		  <div class="content">
			<p class="sui-text-xxlarge my-padd">学生列表</p>
            <!-- 所有课程的列表 -->
            <table class="sui-table table-primary">
                <tr><th>学号</th><th>姓名</th><th>性别</th><th>生日</th><th>籍贯</th><th>手机号</th><th>班号</th><th>照片</th><th>操作</th></tr>
                <tbody id='xuesheng-tr'></tbody>
                <?php
                    include("conn.php");
                    //执行sql语句
                    // <td>{$arr['学号']}</td>
                    // <td>{$arr['姓名']}</td>
                    // <td>".($arr['性别']==0?'女':'男')."</td>
                    // <td>{$arr['生日']}</td>
                    // <td>{$arr['籍贯']}</td>
                    // <td>{$arr['手机号']}</td>
                    // <td>{$arr['班号']}</td>
                    // <td>{$arr['照片']}</td>
                    // <td>
                    //     <a class='sui-btn btn-small btn-warning' href='xuesheng-edit.php?kid={$arr['sid']}'>修改</a>
                    //     <a class='sui-btn btn-small btn-warning' href='xuesheng-del.php?kid={$arr['sid']}'>删除</a>
                    // </td>
                    $sql = "select * from student";
                    $result = mysqli_query($conn,$sql);
                    /* if( mysqli_num_rows($result)>0 ){
                        while ($arr = mysqli_fetch_assoc($result)){
                            echo "<tr id='xuesheng-tr'></tr>";
                        }
                    }else{
                        echo "暂没有记录";
                    } */
                ?>
            </table>
            <div class="xxxx sui-pagination pagination-large">
                <ul>
                    <li class="prev disabled"><a href="#">«上一页</a></li>
                    <li class="active"><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                    <!-- <li><a href="#">4</a></li>
                    <li><a href="#">5</a></li> -->
                    <li class="dotted"><span>...</span></li>
                    <li class="next"><a href="#">下一页»</a></li>
                </ul>
                <div><span>共10页&nbsp;</span><span>
                    到
                    <input type="text" class="page-num"><button class="page-confirm" onclick="alert(1)">确定</button>
                    页</span></div>
                </div>
		  </div>
		</div>		
    </div>
<?php include("foot.php"); ?>
<script>
$('.xxxx').pagination({
    // pages: 50,
    pageSize: 6,//每页显示条数
    itemsCount: 13,//获取记录总条数
    styleClass: ['pagination-large'],
    showCtrl: true,
    displayPage: 7,
    onSelect: function (num) {
        console.log(num);  //打开控制台观察
        getPage(num);
    }        
})
window.onload = function(){
    getPage(1);
}
function getPage(n){
    $.ajax({
        "url":"pagination.php",
        "type":"post",
        "dataType":"json",
        "data":{
            "action":"xuesheng",
            "pagenum":n,
            "pagesize":6
        },
        success:function(data){
            console.log(data);
            var str = "";
            $.each(data.data,function(i,value){
                str += "<tr><td>"+value.学号+"</td><td>"+value.姓名+"</td><td>"+value.性别+"</td><td>"+value.生日+"</td><td>"+value.籍贯+"</td><td>"+value.手机号+"</td><td>"+value.班号+"</td><td>"+value.照片+"</td><td><a class='sui-btn btn-small btn-warning' href='xuesheng-edit.php?kid="+value.sid+"'>修改</a><a style='margin-left:10px;' class='sui-btn btn-small btn-warning' href='xuesheng-del.php?kid="+value.sid+"'>删除</a></td></tr>";
            })
            $("#xuesheng-tr").html(str);
        }
    })
}
</script>
